import Router from 'koa-router';
import userRoutes from './user';
import authRoutes from './auth';
import menuRoutes from './menu';
import dictItemRoutes from './dictItem';
import configRoutes from './config';
import dictRoutes from './dict';
import logRoutes from './log';
import orgRoutes from './org';
import roleRoutes from './role';

export const prefix = '/admin';
const routes = [];

const router = new Router({
    prefix,
});

// 添加各模块路由
routes.push(...userRoutes);
routes.push(...authRoutes);
routes.push(...menuRoutes);
routes.push(...dictItemRoutes);
routes.push(...configRoutes);
routes.push(...dictRoutes);
routes.push(...logRoutes);
routes.push(...orgRoutes);
routes.push(...roleRoutes);

routes.forEach((route) => {
    router[route.method](route.name, route.path, ...route.middlewares);
});

export default router;
